package com.qs.javame.thread.join;

public class TestJoin2 {

    public static void main(String[] args) {

        Thread currentThread = Thread.currentThread();

        Task task = new Task(currentThread);
        Thread thread = new Thread(task);
        thread.start();

        try {
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
            System.out.println(Thread.currentThread().getName() + "-中断：" + Thread.currentThread().isInterrupted());
        }

        System.out.println(Thread.currentThread().getName() + "执行完成了~");

    }


    static class Task implements Runnable {

        private Thread thread;

        public Task(Thread thread) {
            this.thread = thread;
        }

        @Override
        public void run() {
            thread.interrupt();
            System.out.println(Thread.currentThread().getName() + "-执行完成~");
        }
    }
}
